package com.elong.spring.advice;

import org.springframework.aop.BeforeAdvice;
import org.springframework.aop.framework.ProxyFactory;

public class TestBeforeAdvice {

    public static void main(String[] args) {
	Waiter target = new NaiveWaiter();
	BeforeAdvice advice = new GreetingBeforeAdvice();
	//spring使用的代理工厂
	ProxyFactory pf = new ProxyFactory();
	
	//2 设置目标
	pf.setTarget(target);
	
	//3 为代理类设置增强目标
	pf.addAdvice(advice);
	
	//4 生成代理对象
	Waiter proxy = (Waiter) pf.getProxy();
	
	proxy.greetTo("Hohn");
	proxy.greetTo("Tom");
	
    }
}
